Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
The memory-fs npm package is an in-memory filesystem that mimics the Node.js fs module. It allows you to create, read, write, and delete files and directories in memory, which can be useful for testing or when you need a temporary filesystem that does not interact with the actual disk.
Creating and writing files
This feature allows you to create new files and write content to them, similar to fs.writeFileSync in Node.js.
{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.writeFileSync('/my-file.txt', 'Hello World');"}
Reading files
This feature allows you to read the contents of files that exist in the in-memory filesystem.
{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.writeFileSync('/my-file.txt', 'Hello World');\nconst content = fs.readFileSync('/my-file.txt', 'utf-8');"}
Creating directories
This feature allows you to create directories within the in-memory filesystem.
{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.mkdirSync('/my-directory');"}
Deleting files and directories
This feature allows you to delete files and directories from the in-memory filesystem.
{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.writeFileSync('/my-file.txt', 'Hello World');\nfs.unlinkSync('/my-file.txt');\nfs.mkdirSync('/my-directory');\nfs.rmdirSync('/my-directory');"}
memfs is an in-memory filesystem with the same API as Node.js fs module. It is similar to memory-fs but is actively maintained and has additional features like volume serialization and deserialization.
unionfs allows you to create a union of multiple filesystems. While it can work with in-memory filesystems, it can also combine real filesystems and has a broader scope compared to memory-fs.
mock-fs is a library for mocking the Node.js fs module. It allows you to intercept file system operations and provide custom in-memory implementations. It is primarily used for testing purposes and offers a different approach compared to memory-fs.
A simple in-memory filesystem. Holds data in a javascript object.
var MemoryFileSystem = require("memory-fs");
var fs = new MemoryFileSystem(); // Optionally pass a javascript object
fs.mkdirpSync("/a/test/dir");
fs.writeFileSync("/a/test/dir/file.txt", "Hello World");
fs.readFileSync("/a/test/dir/file.txt"); // returns Buffer("Hello World")
// Async variantes too
fs.unlink("/a/test/dir/file.txt", function(err) {
// ...
});
fs.readdirSync("/a/test"); // returns ["dir"]
fs.statSync("/a/test/dir").isDirectory(); // returns true
fs.rmdirSync("/a/test/dir");
fs.mkdirpSync("C:\\use\\windows\\style\\paths");
Copyright (c) 2012-2014 Tobias Koppers
FAQs
A simple in-memory filesystem. Holds data in a javascript object.
We found that memory-fs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.